package com.ice.netty.modbus.data;

import com.ice.netty.modbus.config.MiiMessage;

public class MiiServerDataFactory implements MiiDataFactory {
    @Override
    public MsgBaseData buildData(int command, byte[] datas) {
        MsgBaseData data = null;
        switch (command) {
            case MiiMessage.HEART_COMMAND:
                data = new MiiHeartBeatData(datas);
                break;

            case MiiMessage.DEVICE_NO_COMMAND:
                data = new DeviceInfoData(datas);
                break;
            case MiiMessage.BACK_LIGHT_COMMAND:
                data = new BackLightData(datas);
                break;
            case MiiMessage.CARD_COMMAND:
                data = new SwipeCardData(datas);
                break;
            case MiiMessage.SCAN_CODE_COMMAND:
                data = new ScanCodeData(datas);
                break;
            default:
                String error = " request type " + command + " not supported";
                return null;
        }
        return data;
    }
}
